import java.util.Arrays;
import java.util.Random;

public class Test {

    //有序数组
    public static void orderArray(int[] array){
        for (int i = 0; i < array.length; i++) {
            array[i]=i;
        }
    }
    //逆序数组
    public static void notorderArray(int[] array){
        for (int i = 0; i < array.length; i++) {
            array[i]=array.length-i;
        }
    }
    //随机数组
    public static void notorderArrayRandom(int[] array){
        Random random=new Random();
        for (int i = 0; i < array.length; i++) {
            array[i]= random.nextInt(10_0000);
        }
    }

    public static void inserttestSort(int[] array){
        int[] tmpArray=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        Sort.insertSort(tmpArray);
        long endTime=System.currentTimeMillis();
        /*System.out.println(Arrays.toString(tmpArray));*/
        System.out.println("插入排序花费时间"+(endTime-startTime));//1195
    }

    public static void shelltestSort(int[] array){
        int[] tmpArray=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        Sort.shellSort(tmpArray);
        long endTime=System.currentTimeMillis();
        /*System.out.println(Arrays.toString(tmpArray));*/
        System.out.println("希尔排序花费时间"+(endTime-startTime));//7
    }

    public static void selecttestSort(int[] array){
        int[] tmpArray=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        Sort.selectSort(tmpArray);
        long endTime=System.currentTimeMillis();
        /*System.out.println(Arrays.toString(tmpArray));*/
        System.out.println("选择排序花费时间"+(endTime-startTime));//2303
    }

    public static void testquickSort(int[] array){
        int[] tmpArray=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        Sort.quickSort(tmpArray);
        long endTime=System.currentTimeMillis();
        /*System.out.println(Arrays.toString(tmpArray));*/
        System.out.println("快速排序花费时间"+(endTime-startTime));//2303
    }

    public static void testMergeSort(int[] array){
        int[] tmpArray=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        Sort.mergeSort(tmpArray);
        long endTime=System.currentTimeMillis();
        /*System.out.println(Arrays.toString(tmpArray));*/
        System.out.println("归并排序花费时间"+(endTime-startTime));//2303
    }

    public static void main1(String[] args) {
        int[] array=new int[10_0000];
        notorderArray(array);
        shelltestSort(array);
        inserttestSort(array);
        selecttestSort(array);
        testquickSort(array);
        testMergeSort(array);
    }

    public static void main(String[] args) {
        int[] array={6,21,3,4,5,7};
        Sort.shellSort(array);
        System.out.println(Arrays.toString(array));
    }
}
















